class Exploitdb < Formula
  desc "Database of public exploits and corresponding vulnerable software"
  homepage "https://www.exploit-db.com/"
  url "https://gitlab.com/exploit-database/exploitdb.git",
      tag:      "2024-08-29",
      revision: "32e0cc5e7f2c28418a054c00894482b7d922f1d0"
  license "GPL-2.0-or-later"
  head "https://gitlab.com/exploit-database/exploitdb.git", branch: "main"

  bottle do
    sha256 cellar: :any_skip_relocation, arm64_sequoia:  "50ead7b7c1ac5865ebb32b2e0719deb37818ba64f6924ff09a1a140257ab4edc"
    sha256 cellar: :any_skip_relocation, arm64_sonoma:   "e5b0e6a34961e09f9f7be2e52902527e89f267bd3bdf473ef4c2512af33173d8"
    sha256 cellar: :any_skip_relocation, arm64_ventura:  "3b34081a9f3fe8213fbd7bbd2f2b6c33efb04a58412f21adc00ce6b7441bfedb"
    sha256 cellar: :any_skip_relocation, arm64_monterey: "9867b09a089d026a7e62ca704f112eb4bba5b202c54c6715f0096774a21c810a"
    sha256 cellar: :any_skip_relocation, sonoma:         "0c7ae3dfe277b5bce05a535a9c056be254ae260dd46c445df520414df0efa626"
    sha256 cellar: :any_skip_relocation, ventura:        "a7beaf4816ae10e4a859c043b2dce424a34f0e2a30738b776e38e43985476f8f"
    sha256 cellar: :any_skip_relocation, monterey:       "edb0a277fcfdd356a718b249ffb6882c522b470bf1fcd0fe41af32996f4331af"
    sha256 cellar: :any_skip_relocation, x86_64_linux:   "8f0827cba61105f5c5243280b209fd7df412ed8b4a4e8535ecb09c53e9d9c79f"
  end

  def install
    inreplace "searchsploit",
              "rc_file=\"\"", "rc_file=\"#{etc}/searchsploit_rc\""

    optpath = opt_share/"exploitdb"
    inreplace ".searchsploit_rc" do |s|
      s.gsub! "\"/opt/exploitdb\"", optpath
      s.gsub! "\"/opt/exploitdb-papers\"", "#{optpath}-papers"
    end

    bin.install "searchsploit"
    etc.install ".searchsploit_rc" => "searchsploit_rc"

    pkgshare.install %w[.git exploits files_exploits.csv files_shellcodes.csv
                        shellcodes]
  end

  test do
    system bin/"searchsploit", "sendpage"
  end
end
